/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package light;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.lang.Math.*;

/**
 *
 * @author Дмитрий
 */
public class Ray {
//цвет луча (your captain obvious)

    private final Color color;
//толщина луча в пикселях
    private static int width = 3;
//координаты начала
    private int x1;
    private int y1;
//координаты конца    
    private int x2;
    private int y2;
//конструктор

    public Ray(int x1, int y1, int x2, int y2, int width, Color color) {
        this.x1 = x1;
        this.y1 = y1;
        this.x2 = x2;
        this.y2 = y2;
        this.width = width;
        this.color = color;
    }

    public Ray(int x1, int y1, int x2, int y2, Color color) {
        this.x1 = x1;
        this.y1 = y1;
        this.x2 = x2;
        this.y2 = y2;
        this.color = color;
    }

// "рисование" луча
    public void draw(Graphics gr) {
//        double xd1 = (double) x1, xd2 = (double) x2, yd1 = (double) y1, yd2 = (double) y2;
        Graphics2D g = (Graphics2D) gr;
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setPaint(color);
        /*
        g.setPaint(new LinearGradientPaint(new Point2D.Double(xd1, yd1), new Point2D.Double(xd2, yd2),
                new float[]{0f, 0.25f, 0.5f, 0.75f, 1f},
                new Color[]{Color.WHITE, Color.RED, Color.GREEN, Color.BLUE, Color.BLACK},
                MultipleGradientPaint.CycleMethod.REPEAT, MultipleGradientPaint.ColorSpaceType.SRGB,
                AffineTransform.getRotateInstance(PI/2)));
        */
        g.setStroke(new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
        g.drawLine(x1, y1, x2, y2);
        g.setPaint(new Color(color.getRed(), color.getGreen(), color.getBlue(), 100));
        g.setStroke(new BasicStroke(width * 2 + 3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
        g.drawLine(x1, y1, x2, y2);
    }

//get'теры
public int getX1() {
        return x1;
    }

    public int getY1() {
        return y1;
    }

    public int getX2() {
        return x2;
    }

    public int getY2() {
        return y2;
    }
    
    public static int getWidth() {
        return width;
    }
    
    public Color getColor() {
        return color;
    }

//set'теры
    public void setX1(int x1) {
        this.x1 = x1;
    }

    public void setY1(int y1) {
        this.y1 = y1;
    }

    public void setX2(int x2) {
        this.x2 = x2;
    }

    public void setY2(int y2) {
        this.y2 = y2;
    }

}
